package com.lik.littleworld.web.controller;

import com.lik.littleworld.common.BaseResult;
import com.lik.littleworld.common.auth.AuthResponse;
import com.lik.littleworld.web.config.YiBanConfig;
import com.lik.littleworld.web.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AuthController {


    @Autowired
    private YiBanConfig yiBanConfig;

    @Autowired
    private AuthService authService;

    @RequestMapping("/authorize")
    public BaseResult auth(@RequestParam("verify_request") String verify_request) {
// StringUtils
//         if(verify_request)
        AuthResponse authResponse = authService.requestUserInfo(verify_request, yiBanConfig.getAppSecret(), yiBanConfig.getAppID());
        return BaseResult.success(authResponse.getVisit_user());
    }


}
